/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package util.ejb;

import entities.tools.Form;
import entities.users.FormOwner;
import java.util.List;
import javax.ejb.Local;

/**
 *
 * @author Marek
 */
@Local
public interface FormOwnerBeanInterface {

    /**
     * Method creates new FormOwner instance
     *
     * @return new FormOwner instance
     */
    FormOwner createFormOwner();

    /**
     * Method deletes specified by detachedFormOnwer entity
     *
     * @param detachedFormOwner
     * @return true if operation succeeded, false - if not
     */
    boolean deleteFormOwner(FormOwner detachedFormOwner);

    /**
     * (Dangerous) Method is bypasses security policy. Normally FormOwner cannot
     * be deleted, when he had filled some forms before. Method is performing
     * delete operation on all instances of FilledForm entity related to the
     * Form Owner, specified by pram, and than it deletes also that FormOwner
     * entity, specified by param.
     *
     * @param detachedFormOwner
     * @return true - if operation succeeded false - otherwise
     */
    //TODO: Method need to be tested, if it works correctly
    boolean forcedDeleteFormOwner(FormOwner detachedFormOwner);
    //TODO: register the existing form, as a property of the existing form owner
    //TODO: remove the existing form, from the existing form owner, property list
    //TODO: register the existing form signer, as a connected to the form owner
    //TODO: remove the existing form signer, from the form owner connections with form signers list

    /**
     * Method returns all forms owned by entity set in detachedFormOwner param.
     *
     * @param detachedFormOwner
     * @return List of all filled forms
     */
    List<Form> getFilledForms(FormOwner detachedFormOwner);

    /**
     * Method find in the detabase entity specified by id parameter, and returns
     * this entity
     *
     * @param id
     * @return founded FormOwner
     */
    FormOwner getFormOwner(Long id);

    /**
     * Method returns all FormOwner entities from the database
     *
     * @return all FormOwner from the database
     */
    List<FormOwner> getFormOwners();

    //updates the existing form owner
    /**
     * Method updates in the database, specified by detachedFormOwner entity
     *
     * @param detachedFormOwner
     * @return true if operation succeeded, false - if not
     */
    boolean updateFormOwner(FormOwner detachedFormOwner);
    
}
